﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ContractManagementSystem.BusinessLogicLayer;
using ContractManagementSystem.EntityObjects;

namespace ContractManagementSystem.Presentation
{
    public partial class LogOn : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void ButtonLogOnClick(object sender, EventArgs e)
        {
            var accountEntity = AdministrationUtilityLogic.Authenticate(UserName.Text, Password.Text);

            if (accountEntity != null)
            {
                Session["UserName"] = accountEntity.UserName;
                Session["RoleId"] = accountEntity.RoleId;

                // Because of logon page without master page. So we can not use Page.Master.ResolveUrl
                Response.Redirect("Default.aspx");
            }
            else
            {
                ResultMessage.Text = "User name or password is not valid.";
            }
        }
    }
}
